#include <iostream>
#include <cstring>
#include "StackOfIntegers.h"
using namespace std;

class EmptyStackException : public runtime_error
{
public:
  EmptyStackException() : runtime_error("Empty Stack Exception")
  {
  }
};

StackOfIntegers::StackOfIntegers()
{
  size = 0;
}

bool StackOfIntegers::empty()
{
  return (size == 0);
}

int StackOfIntegers::peek()
{
  if (size == 0)
    throw EmptyStackException();

  return elements[size - 1];
}

int StackOfIntegers::push(int value)
{
  return elements[size++] = value;
}

int StackOfIntegers::pop()
{
  if (size == 0)
    throw EmptyStackException();
  return elements[--size];
}

int StackOfIntegers::getSize()
{
  return size;
}
